﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace ACNetMusicClient
{
    [Serializable]
    public class SongServerClientDTO
    {
        [NonSerialized]
        public Socket socket;
        [NonSerialized]
        public List<byte> tranmissionBuffer = new List<byte>();
        [NonSerialized]
        public byte[] buffer = new byte[1024];

        public ArrayList songs; // the only thing we really send

        public byte[] serialize()
        {
            BinaryFormatter bin = new BinaryFormatter();
            MemoryStream mem = new MemoryStream();
            bin.Serialize(mem, this);
            return mem.GetBuffer();
        }

        public SongServerClientDTO deSerialize()
        {
            byte[] dataBuffer = tranmissionBuffer.ToArray();
            BinaryFormatter bin = new BinaryFormatter();
            MemoryStream mem = new MemoryStream();
            mem.Write(dataBuffer, 0, dataBuffer.Length);
            mem.Seek(0, 0);
            return (SongServerClientDTO)bin.Deserialize(mem);
        }
    }
}
